<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 润
  Date: 2021/7/26
  Time: 15:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $("button[id=delete]").each(function () {
                $(this).bind("click",function () {
                    var cid = $(this).attr("value");
                    $.ajax({
                        type: "POST",
                        url: "http://localhost:8080/Anyview/ManagerServlet?action=deleteCollege",
                        data: {"cid": cid},
                        success: function (data) {
                            if (data.result1) {
                                alert("删除成功！");
                                window.location.href = "http://localhost:8080/Anyview/ManagerServlet?action=queryAllCollege";
                            }
                        },
                        dataType: "json"
                    })
        })



       /* $(function () {
            $("#delete").click(function () {
                var cid=document.getElementById("delete").value;
                $.ajax({
                    type:"POST",
                    url:"http://localhost:8080/Anyview/ManagerServlet?action=deleteCollege",
                    data:{"cid":cid},
                    success:function (data) {
                        if(data.result1){
                            alert("删除成功！");
                            window.location.href="http://localhost:8080/Anyview/ManagerServlet?action=queryAllCollege";
                        }
                    },
                    dataType:"json"
                })


            })

        })



        }
*/
    </script>
</head>
<body>
<h1 align="center">学院信息页面</h1>
<div><a href="addCollege.jsp">添加学院</a></div>
<div align="center">
    <table>
        <tr>
            <th>序号</th>
            <th>学院名称</th>
        </tr>
        <c:forEach items="${requestScope.colleges}" var="Colleges" varStatus="status"><br>
            <tr>
                <td>${ status.index + 1}</td>
                <td><a href="GradeServlet?action=queryAllGrade&cid=${Colleges.id}">${Colleges.name}</a></td>
                <td><a href="ManagerServlet?action=queryOneCollege&cid=${Colleges.id}">修改</a> </td>
                <td><button id="delete" value="${Colleges.id}">删除</button> </td>
            </tr>
        </c:forEach>
    </table>
</div >
</body>
</html>
